<html><head>
	<meta charset="UTF-8">
	<title>确认付款</title>
	<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no">
	<script src="__PAY__/js/mui.min.js"></script>
	<link href="__PAY__/css/mui.min.css" rel="stylesheet">
	<link rel="stylesheet" href="__PAY__/css/style.css">
	<link rel="stylesheet" href="__PAY__/css/hykcz.css">
<style type="text/css">
	.qrfk_pribox {margin-top: 10px;}
	.qurfk_content {background: #eee; margin-top: 20px; padding-bottom: 0; height: auto;}
	.lianjie a {color:#1DAA39;}
	.lianjie p{float:left;text-align: center;}
	.lianjie .l_left{width:49%}
	.c_left{width:2%;}
	.querfk_btn{font-size:16px}
	.fkcg_tipsbox.qrfk_tipsbox {margin: 4rem auto;}
	.qurfk_topbox .gljye a{top: 0;}
</style></head>

<body class="qurfk_content mui-ios mui-wechat mui-ios-10 mui-ios-10-2 mui-wechat-6 mui-wechat-6-7 mui-wechat-6-7-3"> 
	<div class="mui-content qrfk_content qurfk_content">
	<form method="post" action="/index/pay/check_money.html" id="myform">
		<div class="qurfk_topbox">
		<div class="qrfk_nambox">
				<div class="nambox">
					<p><img style="width: 85px;height: 85px;border-radius:5px;" id='store_thum' src="{$agent_info['logo']}"></p>
					<p>{$agent_info['agent_name']}</p>
				</div>
		</div>
		<div class="gljye clearfix"><em id="balance" style="color: red;">{$score?$score:'0.00'}</em>鼓励金剩余</div>
		<div class="gljdk clearfix"><em id="t1">￥0.00</em>本单可节省</div>
		<!-- <div class="gljdk clearfix"><em id="t2">{$agent_info.ad_score}%</em>本店优惠</div>
		<div class="gljdk clearfix"><em id="t3">￥{$balance?$balance:'0.00'}</em>累计抵扣</div> -->
		</div>
		<div class="qurfk_topbox">
			<div class="qrfk_pribox">
				<span style="font-size:1.3rem; height: 3rem; line-height: 3rem;">¥</span>
                <span class='input' placeholder='输入金额' class="qrfk_srk" name="origin_price" id="origin_price" style="font-size:1.3rem; height: 3rem; line-height: 3rem;background:#fefefe;">输入金额</span>
			</div>
			<!-- <div id="cardpay" >
				<div class="srk"  placeholder="输入不参与优惠金额" name="np_price" id="np_price" >输入不参与优惠金额</div>
			</div> -->
			<button type="button" class="hyk_btn qrfk_btn" id="qrfuk_btn" style="border: none;">确认付款</button>
		</div>
		</form>
		<div class="qurfk_topbox" style="padding-bottom:.5rem;">
		<div class="qrfk_nambox">
				<div class="lianjie clearfix">
						<p class="l_left"><a href="{:url('index/member/index')}" class="querfk_btn">个人中心</a></p>
						<p class="c_left">|</p>
						<p class="l_left"><a href="{:url('index/member/glj_cz')}" class="querfk_btn">充值鼓励金</a></p>
					</div>
			</div>
		</div>
	</div>
</body></html>
{include file="public/clavier" /}
{include file="public/footer" /}
<script>
	$('#qrfuk_btn').click(function(){
		var origin_price = $('#origin_price').text();
		// var np_price = $('#np_price').text();

		if(origin_price.trim()=="" || origin_price.trim()=="|"){
			layer.msg('请输入付款金额');
			return ;
		}

		if(origin_price.trim()==0){
			layer.msg('抱歉！付款金额必须大于0元');
			return ;
		}
		
		// if(np_price.trim()=="输入不参与优惠金额"){
		// 	np_price="0";
		// }
      
		// if(np_price.trim()!="" && np_price.trim()!="输入不参与优惠金额"){
		// 	if(parseFloat(origin_price)<parseFloat(np_price)){
		// 		layer.msg('不参与抵扣金额不能大于总金额!');
		// 		return ;
		// 	}
		// }
		if(isNaN(origin_price.trim())){
			layer.msg('请输入正确的金额');
			return ;
		}

		

		$.ajax({
         	type:"post",
            url:"{:url('index/pay/check_money')}",
            data: {
				    origin_price: origin_price,
					np_price: 0,
					user_id: "{$pay_info['user_id']}", 
					agent_id: "{$pay_info['agent_id']}", 
					store_id: "{$pay_info['store_id']}", 
					clerk_id: "{$pay_info['clerk_id']}", 
					pay_type: "{$pay_info['pay_type']}", 
				},
            success:function(data){
            	if(data.code == 200){
            		location.href = data.url;
            	}else{
            		layer.msg(data.msg);
            	}
                
            },error:function(data){
            	var a = data;
            }
    	});
	});
	    
		//监听总金额输入数值是否变化
		$('#origin_price').on('DOMNodeInserted',function(){
			
		var score = "{$score?$score:'0.00'}";
		var score = parseFloat(score);
		var dk = "{$agent_info.ad_score}";
		var dk = dk/100;
		
		var origin_price = $('#origin_price').text();
		var np_price = $('#np_price').text();
		var dk_score = 0;
		if(!origin_price){
			$('#origin_price').text("0");
		}
		if(np_price && np_price!="输入不参与优惠金额"){
		    dk_score = (origin_price-np_price)*dk;
		}else{
			dk_score = origin_price*dk;
		}
		var dk = dk_score.toFixed(2);
		
		if(score <= 0){ 
			if(isNaN(dk)){
				$('#t1').text("￥"+"0.00");
			}else{
			$('#t1').text("￥"+dk);
			}
		}else{
			if(dk>0){ 
				$('#t1').text("￥"+dk);
			}else{ 
				$('#t1').text("￥"+"0.00");
			}
		}
	});
	// //监听不参与抵扣金额输入数值是否变化
	// $('#np_price').on('DOMNodeInserted',function(){
			
	// 		var score = "{$score?$score:'0.00'}";
	// 		var score = parseFloat(score);
	// 		var dk = "{$agent_info.ad_score}";
	// 		var dk = dk/100;
			
	// 		var origin_price = $('#origin_price').text();
	// 		var np_price = $('#np_price').text();
	// 		var dk_score = 0;
	// 		if(!origin_price){
	// 			$('#origin_price').text("0");
	// 		}
	// 		if(np_price){
	// 			dk_score = (origin_price-np_price)*dk;
	// 		}else{
	// 			dk_score = origin_price*dk;
	// 		}
	// 		var dk = dk_score.toFixed(2);
	// 		if(score <= 0){ 
	// 			$('#t1').text("￥"+dk);
	// 		}else{
	// 			if(dk>0){ 
	// 				$('#t1').text("￥"+dk);
	// 			}else{ 
	// 				$('#t1').text("￥"+"0.00");
	// 			}
	// 		}
	// 	});
	</script>